home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / yatzys_1 / yatzy.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-10-22  |  24.3 KB  |  731 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form frmYatzy 
  4.    BackColor       =   &H00C0FFFF&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Yatzy"
  7.    ClientHeight    =   5340
  8.    ClientLeft      =   90
  9.    ClientTop       =   1380
  10.    ClientWidth     =   9090
  11.    Icon            =   "yatzy.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    PaletteMode     =   1  'UseZOrder
  15.    ScaleHeight     =   356
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   606
  18.    StartUpPosition =   2  'CenterScreen
  19.    Begin MSFlexGridLib.MSFlexGrid grdScoreBoard 
  20.       Height          =   4665
  21.       Left            =   240
  22.       TabIndex        =   0
  23.       Top             =   240
  24.       Width           =   5085
  25.       _ExtentX        =   8969
  26.       _ExtentY        =   8229
  27.       _Version        =   65541
  28.       Rows            =   19
  29.       Cols            =   11
  30.       FixedRows       =   0
  31.       FixedCols       =   0
  32.       BackColorBkg    =   12632256
  33.       Redraw          =   -1  'True
  34.       Enabled         =   -1  'True
  35.       HighLight       =   0
  36.       GridLinesFixed  =   1
  37.       ScrollBars      =   0
  38.    End
  39.    Begin VB.PictureBox picDice 
  40.       Appearance      =   0  'Flat
  41.       BackColor       =   &H00C0FFFF&
  42.       BorderStyle     =   0  'None
  43.       ForeColor       =   &H80000008&
  44.       Height          =   480
  45.       Index           =   4
  46.       Left            =   7320
  47.       ScaleHeight     =   480
  48.       ScaleWidth      =   480
  49.       TabIndex        =   6
  50.       Top             =   3240
  51.       Width           =   480
  52.    End
  53.    Begin VB.PictureBox picDice 
  54.       Appearance      =   0  'Flat
  55.       BackColor       =   &H00C0FFFF&
  56.       BorderStyle     =   0  'None
  57.       ForeColor       =   &H80000008&
  58.       Height          =   480
  59.       Index           =   3
  60.       Left            =   6600
  61.       ScaleHeight     =   480
  62.       ScaleWidth      =   480
  63.       TabIndex        =   5
  64.       Top             =   3240
  65.       Width           =   480
  66.    End
  67.    Begin VB.PictureBox picDice 
  68.       Appearance      =   0  'Flat
  69.       BackColor       =   &H00C0FFFF&
  70.       BorderStyle     =   0  'None
  71.       ForeColor       =   &H80000008&
  72.       Height          =   480
  73.       Index           =   2
  74.       Left            =   7680
  75.       ScaleHeight     =   480
  76.       ScaleWidth      =   480
  77.       TabIndex        =   4
  78.       Top             =   2520
  79.       Width           =   480
  80.    End
  81.    Begin VB.PictureBox picDice 
  82.       Appearance      =   0  'Flat
  83.       BackColor       =   &H00C0FFFF&
  84.       BorderStyle     =   0  'None
  85.       ForeColor       =   &H80000008&
  86.       Height          =   480
  87.       Index           =   1
  88.       Left            =   6960
  89.       ScaleHeight     =   480
  90.       ScaleWidth      =   480
  91.       TabIndex        =   3
  92.       Top             =   2520
  93.       Width           =   480
  94.    End
  95.    Begin VB.PictureBox picDice 
  96.       Appearance      =   0  'Flat
  97.       BackColor       =   &H00C0FFFF&
  98.       BorderStyle     =   0  'None
  99.       DrawStyle       =   5  'Transparent
  100.       FillStyle       =   0  'Solid
  101.       ForeColor       =   &H00FFFFFF&
  102.       Height          =   480
  103.       Index           =   0
  104.       Left            =   6240
  105.       ScaleHeight     =   480
  106.       ScaleWidth      =   480
  107.       TabIndex        =   2
  108.       Top             =   2520
  109.       Width           =   480
  110.    End
  111.    Begin VB.Timer Timer1 
  112.       Enabled         =   0   'False
  113.       Interval        =   50
  114.       Left            =   5520
  115.       Top             =   4320
  116.    End
  117.    Begin VB.CommandButton cmdHitMe 
  118.       Height          =   735
  119.       Left            =   6120
  120.       TabIndex        =   1
  121.       Top             =   4080
  122.       Width           =   2175
  123.    End
  124.    Begin VB.Image imgNumber 
  125.       Appearance      =   0  'Flat
  126.       Height          =   480
  127.       Index           =   5
  128.       Left            =   8400
  129.       Picture         =   "yatzy.frx":030A
  130.       Top             =   600
  131.       Width           =   480
  132.       Visible         =   0   'False
  133.    End
  134.    Begin VB.Image imgNumber 
  135.       Appearance      =   0  'Flat
  136.       Height          =   480
  137.       Index           =   4
  138.       Left            =   7800
  139.       Picture         =   "yatzy.frx":03DD
  140.       Top             =   600
  141.       Width           =   480
  142.       Visible         =   0   'False
  143.    End
  144.    Begin VB.Image imgNumber 
  145.       Appearance      =   0  'Flat
  146.       Height          =   480
  147.       Index           =   3
  148.       Left            =   7200
  149.       Picture         =   "yatzy.frx":04AC
  150.       Top             =   600
  151.       Width           =   480
  152.       Visible         =   0   'False
  153.    End
  154.    Begin VB.Image imgNumber 
  155.       Appearance      =   0  'Flat
  156.       Height          =   480
  157.       Index           =   2
  158.       Left            =   6600
  159.       Picture         =   "yatzy.frx":0577
  160.       Top             =   600
  161.       Width           =   480
  162.       Visible         =   0   'False
  163.    End
  164.    Begin VB.Image imgNumber 
  165.       Appearance      =   0  'Flat
  166.       Height          =   480
  167.       Index           =   1
  168.       Left            =   6000
  169.       Picture         =   "yatzy.frx":063B
  170.       Top             =   600
  171.       Width           =   480
  172.       Visible         =   0   'False
  173.    End
  174.    Begin VB.Image imgNumber 
  175.       Appearance      =   0  'Flat
  176.       Height          =   480
  177.       Index           =   0
  178.       Left            =   5400
  179.       Picture         =   "yatzy.frx":06F9
  180.       Top             =   600
  181.       Width           =   480
  182.       Visible         =   0   'False
  183.    End
  184.    Begin VB.Menu mnuYatzy 
  185.       Caption         =   "&Spel"
  186.       Begin VB.Menu mnuAbout 
  187.          Caption         =   "&Om"
  188.       End
  189.       Begin VB.Menu mnuHighScore 
  190.          Caption         =   "&High-Score"
  191.       End
  192.       Begin VB.Menu mnuNewGame 
  193.          Caption         =   "&Nytt-Spel"
  194.       End
  195.       Begin VB.Menu mnuSound 
  196.          Caption         =   "&Ljud"
  197.          Checked         =   -1  'True
  198.       End
  199.       Begin VB.Menu mnuRestart 
  200.          Caption         =   "&Starta-Om     (Ctrl+click)"
  201.       End
  202.       Begin VB.Menu mnuRegret 
  203.          Caption         =   "&
  204. ngra"
  205.       End
  206.       Begin VB.Menu mnuExit 
  207.          Caption         =   "&Avsluta"
  208.       End
  209.    End
  210. Attribute VB_Name = "frmYatzy"
  211. Attribute VB_GlobalNameSpace = False
  212. Attribute VB_Creatable = False
  213. Attribute VB_PredeclaredId = True
  214. Attribute VB_Exposed = False
  215. '-------------------------------------------------------------------------
  216. 'Code by:   Anders Fransson
  217. 'Email:     anders.fransson@home.se
  218. 'Internet:  http://hem1.passagen.se/fylke
  219. 'Date:      97-07-25
  220. '-------------------------------------------------------------------------
  221. Option Explicit
  222. Private msPlayer(4) As String           'Players name
  223. Private miBonusSum(4) As Integer        'Bonus sum for player
  224. Private miTotalSum(4) As Integer        'Total sum for player
  225. Private miOneToSix(4) As Integer        'Nr of clicks in the 1 to 6 rows for player
  226. Private miRoundSum As Integer           'Sum for a round
  227. Private miPlayer As Integer             'Index of player (1-5)
  228. Private miNrOfPlayers As Integer        'Nr of players (1-5)
  229. Private miThrows As Integer             'Nr of throws for a player (0-3)
  230. Private miThrowsIfRegret As Integer     'The last nr of throws for a player (1-3)
  231. Private miRound As Integer              'Round to play (0-10 if single player)
  232. Private miClickedRows As Integer        'Nr of clicked rows (0-15) for last player
  233. Private miLastClickedRow As Integer     'The last clicked row
  234. Private mbNewGame As Boolean            'True if new game is selected
  235. Public mbGameNotStarted As Boolean      'True if game not is started
  236. Const COLUMN_WIDTH As Integer = 420
  237. Const MAX_PLAYERS As Integer = 5
  238. Const DICE_MOVE As Integer = 150
  239. 'Text constants
  240. Const TEXT_HIT_DICES As String = "sl
  241.  med t
  242. rningarna"
  243. Const TEXT_TWO_LEFT As String = "tv
  244. nger till"
  245. Const TEXT_ONE_LEFT As String = "en g
  246. ng till"
  247. Const TEXT_CLICK_SCORE_BOARD As String = "klicka p
  248.  spelplanen"
  249. Const TEXT_ZERO_POINTS As String = "-"
  250. Const TEXT_RESTART As String = "Ctrl + click = starta om"
  251. Const TEXT_POINTS_BY As String = "po
  252. ng av"
  253. Const TEXT_CHEAT As String = "Fusk Fusk Fusk Fusk Fusk"
  254. 'Registry text constants
  255. Const TEXT_ANDERS_GAMES As String = "Anders Franssons Made In Home Games"
  256. Const TEXT_YATZY As String = "Yatzy"
  257. Const TEXT_PLAYER As String = "Player"
  258. Const TEXT_HIGH_SCORE As String = "High score"
  259. Private Static Sub Form_Load()
  260.     Dim i%
  261.     mbGameNotStarted = True
  262.     'Set grid size
  263.     grdScoreBoard.ColWidth(0) = 1.9 * COLUMN_WIDTH
  264.     For i = 1 To grdScoreBoard.Cols - 1
  265.         grdScoreBoard.ColWidth(i) = COLUMN_WIDTH
  266.     Next
  267.     Me.Show
  268.     'Initialize random number generator
  269.     Randomize
  270.     mbNewGame = True
  271.     mnuRegret.Enabled = False
  272.     NewGame
  273.     mbGameNotStarted = False
  274. End Sub
  275. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  276.     'New game if ctrl is pressed
  277.     If Shift = vbCtrlMask Then
  278.         mbNewGame = False
  279.         NewGame
  280.     End If
  281. End Sub
  282. Private Static Sub cmdHitMe_mouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  283.     Dim i%, iMaxThrows%
  284.     iMaxThrows = 3
  285.     'If you really want to beat the high-score (Ctrl + Shift + Alt + RightClick)
  286.     If Shift = 7 And Button = 2 And X < cmdHitMe.Left - 350 Then
  287.         iMaxThrows = 100
  288.         cmdHitMe.Caption = TEXT_CHEAT
  289.     End If
  290.     'New game if ctrl is pressed, else shuffle dices
  291.     If Shift = vbCtrlMask Then
  292.         NewGame
  293.     Else
  294.         If cmdHitMe.Caption = TEXT_RESTART Then Exit Sub
  295.         mnuRegret.Enabled = False
  296.         miThrows = miThrows + 1
  297.         miThrowsIfRegret = miThrows
  298.         If miThrows <= iMaxThrows Then
  299.             For i = 0 To 4
  300.                 If picDice(i).Top > 150 Then _
  301.                 picDice(i).Picture = imgNumber(Int(6 * Rnd)).Picture
  302.             Next
  303.             Timer1.Enabled = True
  304.         End If
  305.     End If
  306. End Sub
  307. Private Static Sub cmdHitMe_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  308.     Dim i%, j%
  309.     If cmdHitMe.Caption = TEXT_RESTART Then Exit Sub
  310.     If miThrows <= 3 Then
  311.         j = 0
  312.         For i = 0 To 4
  313.             If picDice(i).Top > 150 Then j = j + 1
  314.         Next
  315.         Select Case j
  316.             Case 1: If mnuSound.Checked Then PlaySound App.Path & "\1.wav"
  317.             Case 2, 3: If mnuSound.Checked Then PlaySound App.Path & "\2.wav"
  318.             Case 4, 5: If mnuSound.Checked Then PlaySound App.Path & "\4.wav"
  319.         End Select
  320.     End If
  321.     Select Case miThrows
  322.         Case 1
  323.             cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_TWO_LEFT
  324.             grdScoreBoard.Enabled = True
  325.             For i = 0 To 4
  326.                 picDice(i).Enabled = True
  327.             Next
  328.         Case 2
  329.             cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_ONE_LEFT
  330.         Case Else
  331.             cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_CLICK_SCORE_BOARD
  332.     End Select
  333.     'Stop shuffling dices
  334.     Timer1.Enabled = False
  335. End Sub
  336. Private Static Sub grdScoreBoard_Click()
  337.     Dim i%, j%, iNumberCounter%, iPar%, iTriss%
  338.     'Exit if clicked cell not empty or if wrong player-column
  339.     If Not grdScoreBoard.Text = "" Or Not grdScoreBoard.Col = _
  340.         miRound * miNrOfPlayers + miPlayer Then Exit Sub
  341.     mnuRegret.Enabled = True
  342.     miRoundSum = 0
  343.     miLastClickedRow = grdScoreBoard.Row
  344.     Select Case grdScoreBoard.Row
  345.     Case 0, 7, 8, 18    'Name, sum, bonus, total
  346.         mnuRegret.Enabled = False
  347.         Exit Sub
  348.         
  349.     Case 1, 2, 3, 4, 5, 6
  350.         miOneToSix(miPlayer - 1) = miOneToSix(miPlayer - 1) + 1
  351.         For i = 0 To 4
  352.             If picDice(i).Picture = _
  353.                 imgNumber(grdScoreBoard.Row - 1).Picture Then
  354.                 miRoundSum = miRoundSum + grdScoreBoard.Row
  355.             End If
  356.         Next
  357.         
  358.         'Bonus sum
  359.         miBonusSum(miPlayer - 1) = miBonusSum(miPlayer - 1) + miRoundSum
  360.         'Show bonus-sum if round sum > 0
  361.         If Not miRoundSum = 0 Then
  362.             grdScoreBoard.Row = 7
  363.             If Not miBonusSum(miPlayer - 1) = 0 Then _
  364.                 grdScoreBoard.Text = miBonusSum(miPlayer - 1)
  365.         End If
  366.         
  367.         'Check if bonus
  368.         If miBonusSum(miPlayer - 1) >= 63 Then
  369.             grdScoreBoard.Row = 8
  370.             If Not grdScoreBoard.Text = "50" Then
  371.                 grdScoreBoard.Text = 50
  372.                 miTotalSum(miPlayer - 1) = miTotalSum(miPlayer - 1) + 50
  373.             End If
  374.         Else
  375.             If miOneToSix(miPlayer - 1) = 6 Then
  376.                 grdScoreBoard.Row = 8
  377.                 grdScoreBoard.Text = TEXT_ZERO_POINTS
  378.             End If
  379.         End If
  380.         
  381.     grdScoreBoard.Row = miLastClickedRow
  382.     Case 9 'Ett-par
  383.         miRoundSum = 0
  384.         For i = 5 To 0 Step -1
  385.             iNumberCounter = 0
  386.             For j = 0 To 4
  387.                 If picDice(j).Picture = imgNumber(i).Picture Then _
  388.                     iNumberCounter = iNumberCounter + 1
  389.             Next
  390.             If iNumberCounter >= 2 Then
  391.                 miRoundSum = (i + 1) * 2
  392.                 Exit For
  393.             End If
  394.         Next
  395.     Case 10 'Tv
  396.         miRoundSum = 0
  397.         iPar = 0
  398.         For i = 0 To 5
  399.             iNumberCounter = 0
  400.             For j = 0 To 4
  401.                 If picDice(j).Picture = imgNumber(i).Picture Then _
  402.                     iNumberCounter = iNumberCounter + 1
  403.             Next
  404.             If iPar = 1 And iNumberCounter >= 2 Then
  405.                 miRoundSum = miRoundSum + (i + 1) * 2
  406.                 iPar = iPar + 1
  407.             End If
  408.             If iPar = 0 And iNumberCounter >= 2 Then
  409.                 miRoundSum = miRoundSum + (i + 1) * 2
  410.                 iPar = iPar + 1
  411.             End If
  412.         Next
  413.         If iPar < 2 Then miRoundSum = 0
  414.     Case 11 'Triss
  415.         miRoundSum = 0
  416.         For i = 0 To 5
  417.             iNumberCounter = 0
  418.             For j = 0 To 4
  419.                 If picDice(j).Picture = imgNumber(i).Picture Then _
  420.                     iNumberCounter = iNumberCounter + 1
  421.             Next
  422.             If iNumberCounter >= 3 Then
  423.                 miRoundSum = (i + 1) * 3
  424.                 Exit For
  425.             End If
  426.         Next
  427.     Case 12 'Fyrtal
  428.         miRoundSum = 0
  429.         For i = 0 To 5
  430.             iNumberCounter = 0
  431.             For j = 0 To 4
  432.                 If picDice(j).Picture = imgNumber(i).Picture Then _
  433.                     iNumberCounter = iNumberCounter + 1
  434.             Next
  435.             If iNumberCounter >= 4 Then
  436.                 miRoundSum = (i + 1) * 4
  437.                 Exit For
  438.             End If
  439.         Next
  440.     Case 13 'Liten stege
  441.         miRoundSum = 15
  442.         For i = 0 To 4
  443.             For j = 0 To 4
  444.                 If Not i = j Then
  445.                     If picDice(i).Picture = picDice(j).Picture Or _
  446.                     picDice(i).Picture = imgNumber(5).Picture Then _
  447.                     miRoundSum = 0
  448.                 End If
  449.             Next
  450.         Next
  451.     Case 14 'Stor stege
  452.         miRoundSum = 20
  453.         For i = 0 To 4
  454.             For j = 0 To 4
  455.                 If Not i = j Then
  456.                     If picDice(i).Picture = picDice(j).Picture Or _
  457.                     picDice(i).Picture = imgNumber(0).Picture Then _
  458.                     miRoundSum = 0
  459.                 End If
  460.             Next
  461.         Next
  462.     Case 15 'K
  463.         miRoundSum = 0
  464.         iPar = False
  465.         iTriss = False
  466.         For i = 0 To 5
  467.             iNumberCounter = 0
  468.             For j = 0 To 4
  469.                 If picDice(j).Picture = imgNumber(i).Picture Then _
  470.                     iNumberCounter = iNumberCounter + 1
  471.             Next
  472.             If iNumberCounter = 2 Then
  473.                 miRoundSum = miRoundSum + (i + 1) * 2
  474.                 iPar = True
  475.             End If
  476.             If iNumberCounter = 3 Then
  477.                 miRoundSum = miRoundSum + (i + 1) * 3
  478.                 iTriss = True
  479.             End If
  480.         Next
  481.         If Not iPar Or Not iTriss Then miRoundSum = 0
  482.         
  483.     Case 16 'Chans
  484.         For i = 0 To 4
  485.             For j = 0 To 5
  486.                 If picDice(i).Picture = imgNumber(j).Picture Then _
  487.                     miRoundSum = miRoundSum + j + 1
  488.             Next
  489.         Next
  490.     Case 17 'Yatzy
  491.     If mnuSound.Checked Then PlaySound App.Path & "\Applause.wav"
  492.     miRoundSum = 50
  493.         For i = 1 To 4
  494.             If Not picDice(i).Picture = picDice(0).Picture Then miRoundSum = 0
  495.         Next
  496.     End Select
  497.         
  498.     'Show round-sum
  499.     If miRoundSum = 0 Then
  500.         If mnuSound.Checked Then PlaySound App.Path & "\Boo.wav"
  501.         grdScoreBoard.Text = TEXT_ZERO_POINTS
  502.     Else
  503.         grdScoreBoard.Text = miRoundSum
  504.     End If
  505.     'Show total-sum if round sum > 0
  506.     If Not miRoundSum = 0 Then
  507.         grdScoreBoard.Row = 18
  508.         miTotalSum(miPlayer - 1) = miTotalSum(miPlayer - 1) + miRoundSum
  509.         grdScoreBoard.Text = miTotalSum(miPlayer - 1)
  510.     End If
  511.     'If last player then increase nr of clicked rows
  512.     If miPlayer = miNrOfPlayers Then miClickedRows = miClickedRows + 1
  513.     'If all rows are clicked for the match
  514.     If miClickedRows = grdScoreBoard.Rows - 4 Then
  515.         mnuRegret.Enabled = False
  516.         miRound = miRound + 1
  517.         miClickedRows = 0
  518.         CheckIfHighScore
  519.         
  520.         'Reset players sum
  521.         For i = 1 To miNrOfPlayers
  522.             miTotalSum(i - 1) = 0
  523.             miBonusSum(i - 1) = 0
  524.             miOneToSix(i - 1) = 0
  525.         Next
  526.                
  527.         'If score board is full
  528.         If (miRound + 1) * miNrOfPlayers > 10 Then
  529.             miRound = 0
  530.             cmdHitMe.Caption = TEXT_RESTART
  531.             Exit Sub
  532.         Else
  533.             WritePlayers
  534.         End If
  535.         
  536.     End If
  537.     NextPlayer
  538. End Sub
  539. Private Sub grdScoreBoard_MouseDown(Button As Integer, Shift As Integer, _
  540.                                     X As Single, Y As Single)
  541.     'New game if ctrl is pressed
  542.     If Shift = vbCtrlMask Then
  543.         mbNewGame = False
  544.         NewGame
  545.     End If
  546. End Sub
  547. Private Sub mnuAbout_Click()
  548.     frmAbout.ShowAboutForm TEXT_YATZY, imgNumber(0)
  549. End Sub
  550. Private Sub mnuExit_Click()
  551.     Unload Me
  552.     End
  553. End Sub
  554. Private Sub mnuHighScore_Click()
  555.     'Get high score from registry and show it in a msgbox
  556.     MsgBox GetSetting(TEXT_ANDERS_GAMES, TEXT_YATZY, TEXT_HIGH_SCORE, 0) _
  557.         & " " & TEXT_POINTS_BY & " " & _
  558.         GetSetting(TEXT_ANDERS_GAMES, TEXT_YATZY, TEXT_PLAYER, "?"), _
  559.         vbOKOnly, TEXT_HIGH_SCORE
  560. End Sub
  561. Private Sub mnuNewGame_Click()
  562.     mbNewGame = True
  563.     NewGame
  564. End Sub
  565. Private Sub mnuRestart_Click()
  566.     mbNewGame = False
  567.     NewGame
  568. End Sub
  569. Private Static Sub mnuRegret_Click()
  570.     Dim i%
  571.     'Enable dices again
  572.     For i = 0 To 4
  573.         picDice(i).Enabled = True
  574.     Next
  575.     'Disable the regret menu
  576.     mnuRegret.Enabled = False
  577.     'Update some index
  578.     miThrows = miThrowsIfRegret
  579.     miPlayer = miPlayer - 1
  580.     If miPlayer < 1 Then miPlayer = miNrOfPlayers
  581.     If miPlayer = miNrOfPlayers Then miClickedRows = miClickedRows - 1
  582.     'Update the command button caption
  583.     If miThrows = 1 Then _
  584.         cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_TWO_LEFT
  585.     If miThrows = 2 Then _
  586.         cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_ONE_LEFT
  587.     If miThrows >= 3 Then _
  588.         cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_CLICK_SCORE_BOARD
  589.         
  590.     'Clear the last clicked cell
  591.     grdScoreBoard.Enabled = True
  592.     grdScoreBoard.Row = miLastClickedRow
  593.     grdScoreBoard.Text = ""
  594.     'Update bonus
  595.     If miLastClickedRow < 7 Then
  596.         miOneToSix(miPlayer - 1) = miOneToSix(miPlayer - 1) - 1
  597.         grdScoreBoard.Row = 7
  598.         miBonusSum(miPlayer - 1) = miBonusSum(miPlayer - 1) - miRoundSum
  599.         If miBonusSum(miPlayer - 1) = 0 Then
  600.             grdScoreBoard.Text = ""
  601.         Else
  602.             grdScoreBoard.Text = miBonusSum(miPlayer - 1)
  603.         End If
  604.         
  605.         If miBonusSum(miPlayer - 1) < 63 Then
  606.             grdScoreBoard.Row = 8
  607.             If grdScoreBoard.Text = "50" Then
  608.                 miTotalSum(miPlayer - 1) = miTotalSum(miPlayer - 1) - 50
  609.             End If
  610.             grdScoreBoard.Text = ""
  611.         End If
  612.     End If
  613.     'Update total sum
  614.     grdScoreBoard.Row = 18
  615.     miTotalSum(miPlayer - 1) = miTotalSum(miPlayer - 1) - miRoundSum
  616.     If miTotalSum(miPlayer - 1) = 0 Then
  617.         grdScoreBoard.Text = ""
  618.     Else
  619.         grdScoreBoard.Text = miTotalSum(miPlayer - 1)
  620.     End If
  621. End Sub
  622. Private Sub mnuSound_Click()
  623.     mnuSound.Checked = Not mnuSound.Checked
  624. End Sub
  625. Private Sub picDice_MouseDown(Index As Integer, Button As Integer, _
  626.                                 Shift As Integer, X As Single, Y As Single)
  627.     'Move dice up or down
  628.     If picDice(Index).Top > 150 Then
  629.         picDice(Index).Top = picDice(Index).Top - DICE_MOVE
  630.     Else
  631.         picDice(Index).Top = picDice(Index).Top + DICE_MOVE
  632.     End If
  633. End Sub
  634. Private Static Sub Timer1_Timer()
  635.     Dim i%
  636.     'Shuffle dices
  637.     For i = 0 To 4
  638.         If picDice(i).Top > 150 Then picDice(i).Picture = imgNumber(Int(6 * Rnd)).Picture
  639.     Next
  640. End Sub
  641. Private Static Sub CheckIfHighScore()
  642.         
  643.     Dim i%
  644.     'Loop players and check if high score
  645.     For i = 1 To miNrOfPlayers
  646.         If miTotalSum(i - 1) > GetSetting(TEXT_ANDERS_GAMES, TEXT_YATZY, TEXT_HIGH_SCORE, 0) Then
  647.             SaveSetting TEXT_ANDERS_GAMES, TEXT_YATZY, TEXT_HIGH_SCORE, miTotalSum(i - 1)
  648.             SaveSetting TEXT_ANDERS_GAMES, TEXT_YATZY, TEXT_PLAYER, msPlayer(i - 1)
  649.         End If
  650.     Next
  651. End Sub
  652. Private Static Sub NewGame()
  653.     Dim i%, j%, iTempNrOfPlayers%
  654.     Dim sTempPlayer(4) As String
  655.     Dim strYatzyText As Variant
  656.     strYatzyText = Array("YATZY", "Ettor", "Tv
  657. or", "Treor", "Fyror", _
  658.         "Femmor", "Sexor", "Summa", "Bonus", "Par", "Tv
  659. par", "Triss", _
  660.         "Fyrtal", "l-stege", "s-stege", "K
  661. k", "Chans", "Yatzy", "Summa")
  662.     'If new game then input players
  663.     If mbNewGame Then
  664.         'Input nr of players
  665.         iTempNrOfPlayers = Val(frmInput.ShowInputForm(Me))
  666.         If iTempNrOfPlayers = -1 Then Exit Sub
  667.         
  668.         'Input player names
  669.         For i = 1 To iTempNrOfPlayers
  670.             sTempPlayer(i - 1) = frmInput.ShowInputForm(Me, i)
  671.             If sTempPlayer(i - 1) = "-1" Then Exit Sub
  672.         Next i
  673.         
  674.         'If not cancel
  675.         miNrOfPlayers = iTempNrOfPlayers
  676.         For i = 1 To miNrOfPlayers
  677.             msPlayer(i - 1) = sTempPlayer(i - 1)
  678.         Next i
  679.         
  680.      End If
  681.     Me.Refresh
  682.     miPlayer = 0
  683.     miRound = 0
  684.     miClickedRows = 0
  685.     'Reset players sum
  686.     For i = 0 To MAX_PLAYERS - 1
  687.         miTotalSum(i) = 0
  688.         miBonusSum(i) = 0
  689.         miOneToSix(i) = 0
  690.     Next
  691.     'Show random dices
  692.     For i = 0 To 4
  693.         picDice(i).Picture = imgNumber(Int(6 * Rnd)).Picture
  694.     Next
  695.     'Clear grid and write text in first column
  696.     grdScoreBoard.Clear
  697.     grdScoreBoard.Col = 0
  698.     grdScoreBoard.FontBold = True
  699.     For i = 0 To grdScoreBoard.Rows - 1
  700.         grdScoreBoard.Row = i
  701.         grdScoreBoard.Text = strYatzyText(i)
  702.     Next
  703.     mnuRegret.Enabled = False
  704.     mbNewGame = False
  705.     WritePlayers
  706.     NextPlayer
  707. End Sub
  708. Private Static Sub NextPlayer()
  709.     Dim i%
  710.     miThrows = 0
  711.     'Change player
  712.     miPlayer = miPlayer + 1
  713.     If miPlayer = miNrOfPlayers + 1 Then miPlayer = 1
  714.     cmdHitMe.Caption = msPlayer(miPlayer - 1) & ", " & TEXT_HIT_DICES
  715.     'Disable and place dices
  716.     grdScoreBoard.Enabled = False
  717.     For i = 0 To 4
  718.         picDice(i).Enabled = False
  719.         If picDice(i).Top < 150 Then picDice(i).Top = picDice(i).Top + DICE_MOVE
  720.     Next
  721. End Sub
  722. Private Static Sub WritePlayers()
  723.     Dim i%
  724.     'Write player names in 1:st row
  725.     grdScoreBoard.Row = 0
  726.     For i = 1 To miNrOfPlayers
  727.         grdScoreBoard.Col = miRound * miNrOfPlayers + i
  728.         grdScoreBoard.Text = msPlayer(i - 1)
  729.     Next
  730. End Sub
  731.